<script setup lang="ts">
import {Document, Menu as IconMenu, Setting, House, Search} from '@element-plus/icons-vue'
import { useRoute,useRouter } from 'vue-router'
import useDetailStore from '@/store/modules/hospitalDetails.ts'
import {onMounted} from "vue";

//获取路由器
let $route = useRoute();
let $router = useRouter();
let detailStore = useDetailStore();

//组件挂在完毕，通知pinia仓库发请求获取医院详情的数据
onMounted(() => {
  detailStore.getHospital($route.query.hoscode as string)
  //获取某一个医院科室的数据
  detailStore.getDeparment($route.query.hoscode as string)
})

const goto = (path: string) => {
  $router.push({
    path: path,
    query: {
      hoscode: $route.query.hoscode
    }
  })
}
</script>

<template>
  <div class="hospital">
<!--    左侧导航区域-->
    <div class="menu">
      <div class="top">
        <el-icon><House /></el-icon>
        <span>/  医院信息</span>
      </div>
      <el-menu :default-active="$route.path" class="el-menu-vertical-demo">
        <el-menu-item index="/hospital/register" @click="goto('/hospital/register')">
          <el-icon><icon-menu /></el-icon>
          <span>预约挂号</span>
        </el-menu-item>
        <el-menu-item index="/hospital/detail" @click="goto('/hospital/detail')">
          <el-icon><document /></el-icon>
          <span>医院详情</span>
        </el-menu-item>
        <el-menu-item index="/hospital/notice" @click="goto('/hospital/notice')">
          <el-icon><setting /></el-icon>
          <span>预约须知</span>
        </el-menu-item>
        <el-menu-item index="/hospital/close" @click="goto('/hospital/close')">
          <el-icon><setting /></el-icon>
          <span>停诊信息</span>
        </el-menu-item>
        <el-menu-item index="/hospital/search" @click="goto('/hospital/search')">
          <el-icon><Search /></el-icon>
          <span>查询/取消</span>
        </el-menu-item>
      </el-menu>
    </div>

<!--    右侧内容展示区域：路由展示区域-->
    <div class="content">
        <router-view/>
    </div>
  </div>
</template>

<style scoped lang="scss">
.hospital {
  margin-top: 25px;
  display: flex;
  .menu{
    flex: 2;
    display: flex;
    flex-direction: column;
    align-items: center;


    .top{
      color: #7f7f7f;
      margin-bottom: 5px;
      margin-right: 35px;
      span{
        margin-left: 5px;
      }
    }
    .el-menu-vertical-demo{
      //margin-right: 50px;
       margin-top: 10px;
    }
  }
  .content {
    margin-top: 20px;
    flex: 8;
  }
}
</style>
